package com.wwu.system.controller;

import com.wwu.common.enums.MenuBtnEnum;
import com.wwu.common.web.ResultObj;
import com.wwu.system.common.aspect.Log;
import com.wwu.system.entity.SysMenuRole;
import com.wwu.system.service.ISysMenuRoleService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 *  系统菜单角色前端控制器
 * @author 一蓑烟雨
 * @date 2021-10-26
 * @version 1.0.0
 */
@Api(tags = "系统菜单角色控制器(SysMenuRoleController)")
@ApiSort(7)
@RestController
@RequestMapping("/system/sysMenuRole")
public class SysMenuRoleController {
    @Resource
    private ISysMenuRoleService sysMenuRoleService;

    @ApiOperation(value = "根据角色id查询菜单树")
    @ApiOperationSupport(order = 1)
    @GetMapping(value = "/getSysMenuIdsByRoleId/{roleId}")
    public ResultObj getSysMenuIdsByRoleId(@ApiParam(name = "roleId", value = "角色id")
                                                  @PathVariable String roleId){
        return sysMenuRoleService.getSysMenuIdsByRoleId(roleId);
    }

    @Log(menuName = "角色管理",menuBtnEnum = MenuBtnEnum.EDIT)
    @ApiOperation(value = "根据角色id更新权限")
    @ApiOperationSupport(order = 2)
    @PutMapping("/updateMenuRole")
    @ResponseBody
    public ResultObj updateMenuRole(@RequestBody SysMenuRole SysMenuRole){
        sysMenuRoleService.updateMenuRole(SysMenuRole);
        return ResultObj.success("角色授权更新成功");
    }
}